use std::thread;

static NTHREADS: i32 = 10; //定义静态全局的线程数
fn main(){
    //把创建的子线程存放在Vector中
    //let mut children = vec![];
    let mut children = Vec::new();
    for i in 0..NTHREADS {
        //启动另一个线程
        children.push(
            thread::spawn(move || {
                println!("This is thread number {i}");
            }));
    }
    // println!("children:{children:#?}");
    for child in children {
        //等待线程结束。返回一个结果
        let _ = child.join();
    }
}
